﻿using WeDonekRpc.Client;
using WeDonekRpc.Client.Interface;

namespace Basic.UserFormService.Calculate
{
    internal class CurState : IDisposable
    {
        [ThreadStatic]
        public static int? Index;

        [ThreadStatic]
        private static IScoreService _Scope;

        public static IScoreService Scope
        {
            get
            {
                _Scope ??= RpcClient.Ioc.CreateScore();
                return _Scope;
            }
        }

        public CurState ( int? index )
        {
            CurState.Index = index;
        }

        public void Dispose ()
        {
            CurState._Scope?.Dispose();
            CurState.Index = null;
        }
    }
}
